<html>
<head><meta charset="utf-8"><title>LLVM thread use · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html">LLVM thread use</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225478068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/LLVM%20thread%20use/near/225478068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Vandel Sillesen <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html#225478068">(Feb 07 2021 at 18:54)</a>:</h4>
<p>Playing around with -Zself-profile, I see quite a few threads being spawned for LLVM. It seems each LLVM task in this case is quite short. Is this by design?</p>
<p>The below image is from compiling Core.<br>
<a href="/user_uploads/4715/MM6MAuNzPSsDM-1KjfzVC5I0/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/MM6MAuNzPSsDM-1KjfzVC5I0/image.png" title="image.png"><img src="/user_uploads/4715/MM6MAuNzPSsDM-1KjfzVC5I0/image.png"></a></div>



<a name="225478734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/LLVM%20thread%20use/near/225478734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Vandel Sillesen <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html#225478734">(Feb 07 2021 at 19:07)</a>:</h4>
<p>Reading the docs at <a href="https://github.com/rust-lang/rust/blob/b9e5cf99a9acd9c29d02c2f27c0eb223fd0a92be/src/librustc_codegen_ssa/back/write.rs#L1022-L1027">https://github.com/rust-lang/rust/blob/b9e5cf99a9acd9c29d02c2f27c0eb223fd0a92be/src/librustc_codegen_ssa/back/write.rs#L1022-L1027</a><br>
It seems to be by design. It seems somewhat wasteful to spawn new threads for only 7ms (in this case, in could be more expensive i guess)</p>



<a name="225478988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/LLVM%20thread%20use/near/225478988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html#225478988">(Feb 07 2021 at 19:13)</a>:</h4>
<p>I think the idea is to have finer grained artifacts for incremental compilation.</p>



<a name="225479809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/LLVM%20thread%20use/near/225479809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Vandel Sillesen <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html#225479809">(Feb 07 2021 at 19:33)</a>:</h4>
<p>Yeah okay, I guess that makes sense. The docs say that the Jobserver restricts the number of threads running, and they die when done working, so ressource utilization should be ok</p>



<a name="225485451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/LLVM%20thread%20use/near/225485451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/LLVM.20thread.20use.html#225485451">(Feb 07 2021 at 21:41)</a>:</h4>
<p>I imagine that using a pool of threads could remove what overhead in thread creation exists there, but the overall cost of spawning threads is most likely quite negligible for most compilations.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>